package com.hnblc.blcwms.serviceapi.api.enums.result.businiss;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.hnblc.blcwms.common.base.BaseResultEnums;

import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
 * @ClassName: StockQueryResultEnum
 * @Description: TODO
 * @Author: linsong
 * @Date: 2019/8/28
 * @Version: V1.0
 */
public enum  StockQueryResultEnum implements BaseResultEnums {



    SUCCESS(true,"10","查询成功","SUCCESS"),
    NOT_FOUND(false,"21","未找到符合条件的库存信息","STOCK_NOT_FOUND"),
    UNKOWN_ERROR(false,"13","未知查询错误：{0}","UNKOWN_ERROR");

    private String code;
    private String category="31";
    private Boolean isSuccess;
    private String textCn;
    private String testEn;

    StockQueryResultEnum(boolean isSuccess, String code, String textCn, String testEn){
        this.isSuccess = isSuccess;
        this.code = code;
        this.textCn = textCn;
        this.testEn = testEn;
    }

    @Override
    public String code() {
        return this.code;
    }

    @Override
    public String category(){
        return this.category;
    }

    @Override
    public boolean isSuccess(){
        return this.isSuccess;
    }

    @Override
    public String getMessage(){
        return this.getLocaleMessage(Locale.getDefault());
    }


    public String getLocaleMessage(Locale locale) {
        if (Locale.CHINA.equals(locale))
            return this.textCn;
        else return this.testEn;
    }

    private static final List<Map<String, Object>> epte = Lists.newArrayList();

    static {
        for (StockQueryResultEnum enums : EnumSet.allOf(StockQueryResultEnum.class)) {
            Map<String, Object> lookup = Maps.newHashMap();
            lookup.put("code", enums.code());
            lookup.put("textCn", enums.toString());
            lookup.put("testEn", enums.toString());
            epte.add(lookup);
        }
    }

    public static List<Map<String, Object>> statusList() {
        return epte;
    }

}
